<?php

namespace app\common\model;

use app\common\model\BaseModel as BaseModel;
use ShidianUtil\Utils\ConvertUtil;

/**
 * Class CustomPush
 * @package app\common\model
 * @property int $memberId
 * @property int $pushStatus
 * @property string $logic
 * @property string $city
 * @property string $sourceType
 * @property array $kws
 * @property int $updated
 * @property int $created
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037579
 * @link https://www.kancloud.cn/manual/think-orm/1257998
 * @link https://www.kancloud.cn/thinkphp/master-database-and-model/265551
 */
class CustomPush extends BaseModel
{
    protected $name = 'CustomPush';
    protected $pk = 'memberId';

    // 设置json类型字段
    protected $json = ['cityArr', 'sourceTypeArr'];
    protected $jsonAssoc = true;

    public function getCityAttr($value)
    {
        return ConvertUtil::explode($value);
    }

    public function setCityAttr($value)
    {
        return ConvertUtil::implode($value);
    }

    public function getSourceTypeAttr($value)
    {
        return ConvertUtil::explode($value);
    }

    public function setSourceTypeAttr($value)
    {
        return ConvertUtil::implode($value);
    }

    public function getKwsAttr($value)
    {
        return ConvertUtil::explode($value);
    }

    public function setKwsAttr($value)
    {
        return ConvertUtil::implode($value);
    }


    /**
     * 1对1
     * @return \think\model\relation\HasOne
     */
    //    public function one(){
    //        return $this->hasOne( Test1::class, 'Test1表中的键', 'CustomPush表中的键');
    //    }

    /**
     * 1对多
     * @return \think\model\relation\HasMany
     */
    //    public function many(){
    //        return $this->hasMany( Test1::class, 'Test1表中的键', 'CustomPush表中的键');
    //    }

    /**
     * 多对多
     * @return \think\model\relation\BelongsToMany
     */
    //    public function belongs(){
    //        return $this->belongsToMany( Test1::class, '中间表', '中间表中Test1的键', '中间表中CustomPush的键');
    //    }
}
